package com.snack.controller;

import com.snack.entity.dto.DateRangeRequest;
import com.snack.service.ProfitService;
import com.snack.service.SalesReportsService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;

/**
 * @author huangfuhao
 * @Date 2025/4/20
 */
@RestController
@RequestMapping("/api/data")
public class DataController {

    @Resource
    private ProfitService profitService;

    @Resource
    private SalesReportsService salesReportsService;

    @PostMapping("/profit")
    public Object getProfitReportsByDateRange(@RequestBody DateRangeRequest request) {
        return profitService.getProfitReportsByDateRange(request.getStartDate(), request.getEndDate(), request.getStoreId());
    }

    @PostMapping("/sales")
    public Object getSalesReportsByDateRange(@RequestBody DateRangeRequest request) {
        return salesReportsService.getSalesReportsByDateRange(request.getStartDate(), request.getEndDate(), request.getStoreId());
    }
}
